#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1010, mod = 1e9 + 7;

int m, n;
int v[N], w[N];
int f[N];
int g[N];

int main()
{
    cin >> n >> m; // 物品数量和背包容积
    memset(f, -0x3f, sizeof f);
    f[0] = 0;
    g[0] = 1;
    for (int i = 1; i <= n; i ++ )
        cin >> v[i] >> w[i]; // 体积和价值
    
    for (int i = 1; i <= n; i ++ )
        for (int j = m; j >= v[i]; j -- )
        {
            if (f[j] == f[j - v[i]] + w[i])
            {
                g[j] = (g[j] + g[j - v[i]]) % mod;
            } else if (f[j] < f[j - v[i]] + w[i])
                g[j] = g[j - v[i]] % mod;
         
            f[j] = max(f[j], f[j - v[i]] + w[i]);
        }
        
    int res = 0;
    for (int i = 0; i <= m; i ++ ) res = max(res, f[i]);
    int cnt = 0;
    for (int i = 0; i <= m; i ++ )
        if (res == f[i])
            cnt = (cnt + g[i]) % mod;
    cout << cnt << endl;
    return 0;
}

